package com.hengby.hengcrud.modular.mail.model;

import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.Date;

@TableName(value = "oa_email")
@Setter
@Getter
public class OaEmail extends Model<OaEmail> {
	
	/**
	 * 自增主键
	 */
	@TableId(value = "id",type = IdType.AUTO)
	private Long id;
	
	/**
	 * 接收人邮箱(多个逗号分开)
	 */
	@TableField(value = "receive_email")
	private String receiveEmail;
	
	/**
	 * 主题
	 */
	@TableField(value = "subject")
	private String subject;
	
	/**
	 * 发送内容
	 */
	@TableField(value = "content")
	private String content;
	
	/**
	 * 模板
	 */
	@TableField(value = "template")
	private String template;
	
	/**
	 * 发送时间
	 */
	@TableField("send_time")
	private Timestamp sendTime;
	

	@Override
	protected Serializable pkVal() {
		return id;
	}

	public OaEmail(Email mail) {
		this.receiveEmail = Arrays.toString(mail.getEmail());
		this.subject = mail.getSubject();
		this.content = mail.getContent();
		this.template = mail.getTemplate();
		this.sendTime = new Timestamp(new Date().getTime());
	}
}
